package com.tjsinfo.tjsoa.worklog.action;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.worklog.bo.IWorkLogMainBo;
import com.tjsinfo.tjsoa.worklog.vo.WorkLogMain;
public class DeleteWorkLogAction extends Action{
private IWorkLogMainBo workLogMainBo;
	

	public IWorkLogMainBo getWorkLogMainBo() {
	return workLogMainBo;
}


public void setWorkLogMainBo(IWorkLogMainBo workLogMainBo) {
	this.workLogMainBo = workLogMainBo;
}


	/* (non-Javadoc)
	 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		try {
			String id = request.getParameter("id");
			
			
			workLogMainBo.delete(id);
			
			if("list".equals(request.getParameter("type"))&&(request.getParameter("keyword") == null||"".equals(request.getParameter("keyword"))))
			{
				RequestDispatcher   ds   =   request.getRequestDispatcher("workLoglistmode.do?id="+id+"&type="+request.getParameter("logtype")); 
				ds.forward(request,   response);
			}
			else if("list".equals(request.getParameter("type"))&&(request.getParameter("keyword") != null||!"".equals(request.getParameter("keyword"))))
			{
				RequestDispatcher   ds   =   request.getRequestDispatcher("workLogSelect.do?&type="+request.getParameter("logtype")+"&keyword="+request.getParameter("keyword")); 
				ds.forward(request,   response);
			}
			else if("D".equals(request.getParameter("type")))
			{
				request.setAttribute("linkurl", "tjsinfo/tjsoa/worklog/workLogDateModle.do");
				request.setAttribute("message", "worklog.message.delete");
				return mapping.findForward("oklist");
				
			}
			else if("W".equals(request.getParameter("type")))
			{
				request.setAttribute("linkurl", "tjsinfo/tjsoa/worklog/workLogWeekModle.do");
				request.setAttribute("message", "worklog.message.delete");
				return mapping.findForward("oklist");
			}
			else if("M".equals(request.getParameter("type")))
			{
				request.setAttribute("linkurl", "tjsinfo/tjsoa/worklog/workLogMonthModle.do");
				request.setAttribute("message", "worklog.message.delete");
				return mapping.findForward("oklist");
			}
			else if("Q".equals(request.getParameter("type")))
			{
				request.setAttribute("linkurl", "tjsinfo/tjsoa/worklog/workLogJiDuModle.do");
				request.setAttribute("message", "worklog.message.delete");
				return mapping.findForward("oklist");
				
			}
			else if("H".equals(request.getParameter("type")))
			{
				request.setAttribute("linkurl", "tjsinfo/tjsoa/worklog/workLogHalfYearModle.do");
				request.setAttribute("message", "worklog.message.delete");
				return mapping.findForward("oklist");
			}
			else if("Y".equals(request.getParameter("type")))
			{
				request.setAttribute("linkurl", "tjsinfo/tjsoa/worklog/workLogYearModle.do");
				request.setAttribute("message", "worklog.message.delete");
				return mapping.findForward("oklist");
			}
			return mapping.findForward("okY");
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return mapping.findForward("error");
		}
	}
}
